package cs.game.util;

import java.awt.image.BufferedImage;

import cs1.game.main.Game;

public class Mine extends Flyer{
	public char direction;
	public Mine(BufferedImage image,Integer x,Integer y){
		this.image=image;
		this.x=x;
		this.y=y;
		this.Weidth=image.getWidth();
		this.Height=image.getHeight();
		this.speed=20;
	}
	@Override
	public void stepMove() {
		switch(direction){
		case 'w':
			this.y -=speed;
			break;
		case 's':
			this.y +=speed;
			break;
		case 'a':
			this.x -=speed;
			break;
		case 'd':
			this.x +=speed;
			break;
			
		default:
			break;
		}
	}

	@Override
	public boolean OutOfBounds() {
		boolean result=true;
		if(this.y<0){
			this.y = 0;
		}else if(this.y>Game.bgHeigh-this.Height){
			this.y =Game.bgHeigh-this.Height;
		}else if(this.x<0){
			this.x=0;
		}else if(this.x >Game.bgWidth-this.Weidth){
			this.x=Game.bgWidth-this.Weidth;
		}
		else{
		result=false;
		}
		return result;
	}
	public void shoot(){
		BufferedImage zd = Game.bulletImg;
		Bullet b = new Bullet(zd, this.x+(this.Weidth-zd.getWidth())/2, this.y-zd.getHeight(), this);
		Game.bullets.add(b);
	}

}
